﻿(function () {
    connection.on("Everyday", function (txt) {
        let data = JSON.parse(txt);
        console.log(data);
    });
})();
//未完成(待齐套,待签单,待包装,待出箱单,待通知)
(function () {
    connection.on("Unfinished", function (txt) {
        let data = JSON.parse(txt);
        var days = [];//日期
        var data0 = [];//待齐套
        var data1 = [];//待签单
        var data2 = [];//待包装
        var data3 = [];//待出箱单
        var data4 = [];//待通知
        var x0 = 0;//待齐套总数
        var x1 = 0;//待签单总数
        var x2 = 0;//待包装总数
        var x3 = 0;//待出箱单总数
        var x4 = 0;//待通知总数
        for (var i = 0; i < data.length; i++) {

            switch (i) {
                case 0:
                    for (var key in data[i]) {
                        days.push(key),
                            data0.push(data[i][key]);
                        x0 += data[i][key];
                    }
                    break;
                case 1:
                    for (var key in data[i]) {
                        data1.push(data[i][key]);
                        x1 += data[i][key];
                    }
                    break;
                case 2:
                    for (var key in data[i]) {
                        data2.push(data[i][key]);
                        x2 += data[i][key];
                    }
                    break;
                case 3:
                    for (var key in data[i]) {
                        data3.push(data[i][key]);
                        x3 += data[i][key];
                    }
                    break;
                case 4:
                    for (var key in data[i]) {
                        data4.push(data[i][key]);
                        x4 += data[i][key];
                    }
                    break;
            }
        }
        //待齐套
        var mychart0 = echarts.init(document.querySelector('#c10'));
        var option0 = {
            grid: {
                left: 10,
                top: 30,
                right: 150,
                bottom: 10
            },
            legend: {
                data: ["待齐套"],
                right: 10,
                top: '50%',
                formatter: function (arg) {
                    return arg + x0;
                },
                textStyle: {
                    color: "#fff"
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: days,
                axisLine: {
                    show: false
                },
                axisLabel: {
                    show: false
                },
                axisTick: {
                    show: false//坐标轴刻度
                }
            },
            yAxis: {
                type: 'value',
                splitLine: {
                    show: false
                },
                axisLine: {
                    show: false
                },
                axisLabel: {
                    show: false
                }
            },
            series: [
                {
                    name: '待齐套',
                    type: 'line',
                    data: data0,
                    label: {
                        show: true,
                        polition: 'top',
                        color: '#fff',
                        formatter: function (params) {
                            if (params.value > 0) {
                                return params.value;
                            } else {
                                return ' ';
                            }
                        },
                    }
                },
            ]
        };
        mychart0.setOption(option0);
        window.addEventListener('resize', function () {
            mychart0.resize();
        })
        //待签单
        var mychart1 = echarts.init(document.querySelector('#c11'));
        var option1 = {
            grid: {
                left: 10,
                top: 30,
                right: 150,
                bottom: 10
            },
            legend: {
                data: ["待签单"],
                right: 10,
                top: '50%',
                formatter: function (arg) {
                    return arg + x1;
                },
                textStyle: {
                    color: "#fff"
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: days,
                axisLine: {
                    show: false
                },
                axisLabel: {
                    show: false
                },
                axisTick: {
                    show: false//坐标轴刻度
                }
            },
            yAxis: {
                type: 'value',
                splitLine: {
                    show: false
                },
                axisLine: {
                    show: false
                },
                axisLabel: {
                    show: false
                }
            },
            series: [
                {
                    name: '待签单',
                    type: 'line',
                    data: data1,
                    label: {
                        show: true,
                        polition: 'top',
                        color: '#fff',
                        formatter: function (params) {
                            if (params.value > 0) {
                                return params.value;
                            } else {
                                return ' ';
                            }
                        },
                    },
                },
            ]
        };
        mychart1.setOption(option1);
        window.addEventListener('resize', function () {
            mychart1.resize();
        })
        //待包装
        var mychart2 = echarts.init(document.querySelector('#c12'));
        var option2 = {
            grid: {
                left: 10,
                top: 30,
                right: 150,
                bottom: 10
            },
            legend: {
                data: ["待包装"],
                right: 10,
                top: '50%',
                formatter: function (arg) {
                    return arg + x2;
                },
                textStyle: {
                    color: "#fff"
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: days,
                axisLine: {
                    show: false
                },
                axisLabel: {
                    show: false
                },
                axisTick: {
                    show: false//坐标轴刻度
                }
            },
            yAxis: {
                type: 'value',
                splitLine: {
                    show: false
                },
                axisLine: {
                    show: false
                },
                axisLabel: {
                    show: false
                }
            },
            series: [
                {
                    name: '待包装',
                    type: 'line',
                    data: data2,
                    label: {
                        show: true,
                        polition: 'top',
                        color: '#fff',
                        formatter: function (params) {
                            if (params.value > 0) {
                                return params.value;
                            } else {
                                return ' ';
                            }
                        },
                    },
                },
            ]
        };
        mychart2.setOption(option2);
        window.addEventListener('resize', function () {
            mychart2.resize();
        })
        //待出箱单
        var mychart3 = echarts.init(document.querySelector('#c13'));
        var option3 = {
            grid: {
                left: 10,
                top: 30,
                right: 150,
                bottom: 10
            },
            legend: {
                data: ["待出箱单"],
                right: 10,
                top: '50%',
                formatter: function (arg) {
                    return arg + x3;
                },
                textStyle: {
                    color: "#fff"
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: days,
                axisLine: {
                    show: false
                },
                axisLabel: {
                    show: false
                },
                axisTick: {
                    show: false//坐标轴刻度
                }
            },
            yAxis: {
                type: 'value',
                splitLine: {
                    show: false
                },
                axisLine: {
                    show: false
                },
                axisLabel: {
                    show: false
                }
            },
            series: [
                {
                    name: '待出箱单',
                    type: 'line',
                    data: data3,
                    label: {
                        show: true,
                        polition: 'top',
                        color: '#fff',
                        formatter: function (params) {
                            if (params.value > 0) {
                                return params.value;
                            } else {
                                return ' ';
                            }
                        },
                    },
                },
            ]
        };
        mychart3.setOption(option3);
        window.addEventListener('resize', function () {
            mychart3.resize();
        })
        //待通知
        var mychart4 = echarts.init(document.querySelector('#c14'));
        var option4 = {
            grid: {
                left: 10,
                top: 30,
                right: 150,
                bottom: 30
            },
            legend: {
                data: ["待通知"],
                right: 10,
                top: '50%',
                formatter: function (arg) {
                    return arg + x4;
                },
                textStyle: {
                    color: "#fff"
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: days,
                axisLine: {
                    show: true
                },
                axisLabel: {
                    show: true
                },
                axisTick: {
                    show: false//坐标轴刻度
                }
            },
            yAxis: {
                type: 'value',
                splitLine: {
                    show: false
                },
                axisLine: {
                    show: false
                },
                axisLabel: {
                    show: false
                }
            },
            series: [
                {
                    name: '待通知',
                    type: 'line',
                    data: data4,
                    label: {
                        show: true,
                        polition: 'top',
                        color: '#fff',
                        formatter: function (params) {
                            if (params.value > 0) {
                                return params.value;
                            } else {
                                return ' ';
                            }
                        },
                    },
                },
            ]
        };
        mychart4.setOption(option4);
        window.addEventListener('resize', function () {
            mychart4.resize();
        });
    })();
});